package com.yanqu.road.server.cmd.activity.stronghold.wild;

import com.yanqu.road.entity.activity.ActivityInfo;
import com.yanqu.road.pb.activity.StrongholdWarProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.manger.activity.strongholdwar.StrongholdActivityMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.CrossProtocol;
import com.yanqu.road.server.protocol.GameProtocol;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = GameProtocol.S_STRONGHOLD_WAR_OPEN_BOX, desc = "开宝箱")
public class StrongholdWildOpenBoxCmd extends AbstractCommand {
    private int boxId;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        StrongholdWarProto.StrongholdOpenBoxReqMsg req = StrongholdWarProto.StrongholdOpenBoxReqMsg.parseFrom(packet.getBytes());
        boxId = req.getBoxId();
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        //直接发到跨服开宝箱
        ActivityInfo openActivityInfo = StrongholdActivityMgr.getOpenActivityInfo();
        if (openActivityInfo != null) {
            StrongholdWarProto.CrossStrongholdOpenBoxReqMsg.Builder req = StrongholdWarProto.CrossStrongholdOpenBoxReqMsg.newBuilder();
            req.setActivityId(openActivityInfo.getActivityId());
            req.setBoxId(boxId);
            player.sendUnionActivityGroupPacket(CrossProtocol.C_CROSS_STRONGHOLD_WILD_OPEN_BOX, req, req.getActivityId());
        }
    }

    @Override
    public void sendData(GamePlayer player) {

    }
}
